import heapq

class MaxHeap():
    def __init__(self,cap):
        self.cap = cap
        self.list = []
    def push(self, item):
        if len(self.list) >= self.cap:
            if self.list[0] < item:
                heapq.heappop(self.list)
                heapq.heappush(self.list, item)
        else:
            heapq.heappush(self.list, item)
    def getSet(self):
        return set(self.list)
class MinHeap():
    def __init__(self,cap):
        self.cap = cap
        self.list = []
    def push(self, item):
        if len(self.list) >= self.cap:
            if self.list[0]*-1 > item:
                heapq.heappop(self.list)
                heapq.heappush(self.list, item*-1)
        else:
            heapq.heappush(self.list, item*-1)
    def getSet(self):
        l2 = [x*-1 for x in self.list]
        return set(l2)

if __name__ == '__main__':
    # l = MinHeap(2)
    # l.push(5)
    # l.push(6)
    # l.push(-2)
    # l.push(10)
    # l.push(7)
    # l.push(-1)
    # print(l.getSet())
    l = [1,2,3,4,5,6]
    # heapq.heappush(l,2)
    # heapq.heappush(l,6)
    # heapq.heappush(l, 5)
    # heapq.heappush(l, 9)
    # heapq.heappush(l, 10)
    # heapq.heapreplace(l, 8)
    # heapq.heapify(l)
    # heapq.heappush(l,-1)
    heapq.heappop(l)
    heapq.heapreplace(l, -1)
    print(l)

